﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyBlog.Model
{
    [Serializable]
    public class BugModel
    {
        public BugModel()
        {
            BugList = new List<BugModel>();
        }
        public int ID { set; get; }

        public string Visitor { set; get; }

        public string Uid { set; get; }

        public string BugDetail { set; get; }

        public BugModel Parent { set; get; }

        public int? ParentID { set; get; }

        public DateTime SendTime { set; get; }

        public List<BugModel> BugList { set; get; }

        public bool IsLoop { set; get; }

        public string VisitorEmail { set; get; }

        public string AgreeUsers { get; set; }

        public string BugType { set; get; }

        public int AgreeCount
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(AgreeUsers))
                {
                    if (AgreeUsers.Contains("&"))
                    {
                        return AgreeUsers.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Length;
                    }
                    return 1;
                }
                return 0;
            }
        }

        public string TypeStr
        {
            get
            {
                string desc = null;
                switch (BugType)
                {
                    case "1":
                        desc= "404，页面找不到";
                        break;
                    case "2":
                        desc = "JS报错";
                        break;
                    case "3":
                        desc = "样式错乱";
                        break;
                    case "4":
                        desc = "抛出异常";
                        break;
                    case "5":
                        desc = "其他错误";
                        break;
                    default:
                        break;
                }
                return desc;
            }
        }
    }
}
